class Sun extends GuaAnimation {
    static new(game) {
        let p = new this(game, animationsun)
        p.setup()
        return p
    }

    setup() {
        // row表示在草地的第几排
        this.gx = 220
        this.gy = 10
        this.row = -1
        this.column = -1
        this.x = 0
        this.y = -100
        this.k = 1
        this.ky = 0
        this.cooldown = 1000
        this.speed = 5
        this.point = false
        this.realize = true
        this.recycle = false
        this._sleep = true

    }

    awake() {
        this._sleep = false
    }

    sleep() {
        this._sleep = true
    }

    remove(){
        this.scene.removeSun(this)
    }


    update() {
        super.update()
        let y = this.row * 50
        // log('update y', y)
        if (this.realize) {
            if (this.y < y) {
                this.y += this.speed
            }
        }
        if (this.y === y) {
            this.ky = (this.y - this.gy) / this.k
            this.realize = false
        }

    }

    collect() {
        log('collect')
        if (this.k >= 0) {
            this.y -= this.ky
            this.x -= this.speed
            this.k -= 1
        }else {
            this.recycle = true
        }
    }


}